#!/usr/bin/env python

from database import database
import sys

argvs = len(sys.argv)
if argvs < 2:
    print 'This requires minimum two parameters !'
    sys.exit(1)

methode = sys.argv[1]
db = database()

if methode == "insert":
    if argvs != 4:
        print "Insert requires three parameters !"
        sys.exit(1)
    phone = sys.argv[2]
    name = sys.argv[3]
    db.insert(phone, name)
    print "Insert phone number ", phone, " and name ", name, " success"
    
elif methode == "delete":
    if argvs != 3:
        print "Insert requires two parameters !"
        sys.exit(1)
    phone = sys.argv[2]
    db.delete(phone)
    print "Delete phone number ", phone, " success"
    
elif methode == "show":
    show = db.getMember()
    for row in show:
        print row[0]
    
else :
    print "* Unknown command !"
    print "* Usage python member.py {insert|delete|show}"
